﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Webcam
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            t = new Timer();
            t.Interval = 200;
            t.Tick += new EventHandler(t_Tick);
            t.Start();

            Status.Times times = new Webcam.Status.Times();
            times.Show();
        }

        void t_Tick(object sender, EventArgs e)
        {
            UpdateFormText();
        }

        Timer t;

        /// <summary>
        /// Add the panel to the spilt panels panel1
        /// </summary>
        /// <param name="p"></param>
        public void UpdateWebcamPic(int cam, Bitmap img)
        {
            PictureBox pb = null;
            switch (cam)
            {
                case 1 :
                    pb = pictureBox1;
                    break;
                case 2 :
                    pb = pictureBox2;
                    break;
            }
            pb.Image = img;
        }

        private void ScanSize_ValueChanged(object sender, EventArgs e)
        {
            Program.Scan = ScanSize.Value;
            //UpdateFormText();
        }

        public void UpdateFormText()
        {
            this.Text = string.Format("Scan: {0}  Diff: {1} LineDiff: {2} FPS: {3:f}", Program.Scan, Program.Diff, Program.LineDiff, Program.FPS);
        }
        private void DifferenceSize_ValueChanged(object sender, EventArgs e)
        {
            Program.Diff = DifferenceSize.Value;
            //UpdateFormText();
        }

        private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            Program.LineDiff = LineDiff.Value;
        }
    }
}
